import {useDispatch, useSelector} from "react-redux";
import {LOGINSTATE, USERTOKEN} from "../getters/useInfo.ts";
import {setLoginState, setToken} from "../reducers/userInfo.ts";

export const useLoginState = () => useSelector(LOGINSTATE);

export function useDispatchLoginState(){
    const dispatch = useDispatch();
    const setLogin = (payload:boolean) => dispatch(setLoginState(payload));
    return {setLogin};
}

export const useUserToken = () => useSelector(USERTOKEN);
export function  useDispatchUserToken() {
    const dispatch = useDispatch();
    const setUserToken = (payload: string) => dispatch(setToken(payload));
    return {setUserToken};
}